package com.aspose.cells;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

class zajv {
   private Workbook a = null;
   private com.aspose.cells.b.a.d.zm b = null;
   private zoz c = null;
   private com.aspose.cells.a.f.zi d = null;
   private zajm e = null;
   private LoadDataOption f = null;

   static void a(Workbook var0, com.aspose.cells.b.a.d.zm var1, LoadDataOption var2) throws Exception {
      zajv var3 = new zajv(var0, var1, var2);
      var3.a();
   }

   static void a(Workbook var0, com.aspose.cells.a.f.zi var1, LoadDataOption var2) throws Exception {
      zajv var3 = new zajv(var0, var1, var2);
      var3.a();
   }

   zajv(Workbook var1, com.aspose.cells.b.a.d.zm var2, LoadDataOption var3) {
      this.a = var1;
      this.b = var2;
      this.c = new zoz(var1);
      this.f = var3;
   }

   zajv(Workbook var1, com.aspose.cells.a.f.zi var2, LoadDataOption var3) {
      this.a = var1;
      this.d = var2;
      this.c = new zoz(var1);
      this.f = var3;
   }

   void a() throws Exception {
      this.e();
      this.d();
      this.g();
      this.b();
      this.c();
      this.f();
      if (!this.f.getOnlyCreateWorksheet()) {
         this.h();
         this.i();
         this.j();
         this.k();
         this.a.b = null;
         this.d.b();
      }
   }

   private void b() throws Exception {
      String var1 = this.c.g;
      zajw var2 = new zajw(this.c, this.d);
      zcfw var3 = zasr.a(this.d, var1, true);
      if (var3 != null) {
         var2.b(var3);
         var3.c();
      }
   }

   private void c() throws Exception {
      ArrayList var1 = this.c.q;
      if (var1.size() != 0) {
         for(int var2 = 0; var2 < var1.size(); ++var2) {
            zpo var3 = (zpo)var1.get(var2);
            if (var3.a.startsWith("/xl/")) {
               var3.a = var3.a.substring(4);
            }

            String var4 = "xl/" + var3.a;
            String var5 = "xl/" + com.aspose.cells.b.a.d.zk.e(var3.a) + "/_rels/" + com.aspose.cells.b.a.d.zk.b(var3.a) + ".rels";
            HashMap var6 = null;
            zcfw var7;
            if (this.d.a(var5, true) != -1) {
               var7 = zasr.a(this.d, var5, true);
               var6 = zajh.b(var7);
               var7.c();
            }

            var7 = zasr.a(this.d, var4, true);
            zajb var8 = new zajb(this.c, var6);
            var8.a(var7);
            var7.c();
         }

      }
   }

   private void d() {
      this.a.b = new zps(this.a);
   }

   private void e() {
      String var1 = "xl/workbook.xml";

      try {
         if (this.d == null) {
            this.d = com.aspose.cells.a.f.zi.a(this.b);
         }

         if (this.d.a(var1, true) == -1) {
            throw new CellsException(4, "Invalid Excel2007Xlsx file format");
         }
      } catch (Exception var3) {
         throw new CellsException(4, "Invalid Excel2007Xlsx file format");
      }
   }

   private void f() throws Exception {
      String var1 = "xl/workbook.xml";
      zajx var2 = new zajx(this.c);
      zcfw var3 = zasr.a(this.d, var1, true);
      var2.a(var3);
      var3.c();
   }

   private void g() throws Exception {
      String var1 = "xl/_rels/workbook.xml.rels";
      zcfw var2 = zasr.a(this.d, var1, true);
      HashMap var3 = zajh.b(var2);
      this.c.a(var3);
      var2.c();
   }

   private void h() throws Exception {
      zqe var1 = zajh.a(this.c.a(), "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme");
      if (var1 != null) {
         String var2 = "xl/theme/" + com.aspose.cells.b.a.d.zk.b(var1.e);
         if (this.d.a(var2, true) != -1) {
            com.aspose.cells.a.f.zh var3 = this.d.a(var2);
            com.aspose.cells.b.a.d.zm var4 = this.d.a(var3);
            zcfk var5 = zass.a((com.aspose.cells.b.a.d.zm)var4, (zcft)null, true);
            var4.a();
            zajr var6 = new zajr(this.c, var2);
            var6.a(var5, true);
         }
      }

   }

   private void i() throws Exception {
      String var1 = "xl/styles.xml";
      zajp var2 = new zajp(this.c);
      zcfw var3 = zasr.a(this.d, var1, true);
      if (var3 != null) {
         var2.a(var3);
         var3.c();
         var3 = zasr.a(this.d, var1, true);
         var2.b(var3);
         var3.c();
      }
   }

   private void j() throws Exception {
      String var1 = "xl/sharedStrings.xml";
      if (this.d.a(var1, true) != -1) {
         this.e = new zajm(this.c);
         zcfw var2 = zasr.a(this.d, var1, true);
         this.e.a(var2);
         var2.c();
      }

   }

   private void k() throws Exception {
      if (this.e == null) {
         this.e = new zajm(this.c);
      }

      HashMap var1 = this.c.a();
      Iterator var2 = this.c.c.iterator();

      while(var2.hasNext()) {
         zpa var3 = (zpa)var2.next();
         zqe var4 = (zqe)var1.get(var3.c);
         String var5 = com.aspose.cells.b.a.d.zk.b(var4.e);
         if (var4.e.indexOf("worksheets/") != -1) {
            if (this.a(var3)) {
               this.a(var3, var5);
            }
         } else if (var4.e.indexOf("chartsheets/") != -1 && zase.b) {
            ;
         }
      }

   }

   private boolean a(zpa var1) {
      if (this.f == null) {
         return true;
      } else {
         int var2;
         if (this.f.SheetIndexes != null) {
            for(var2 = 0; var2 < this.f.SheetIndexes.length; ++var2) {
               int var4 = this.f.SheetIndexes[var2];
               if (var1.a == var4) {
                  return true;
               }
            }

            return false;
         } else if (this.f.SheetNames != null) {
            for(var2 = 0; var2 < this.f.SheetNames.length; ++var2) {
               String var3 = this.f.SheetNames[var2];
               if (var3 != null && com.aspose.cells.b.a.zv.b(var1.d.getName().toLowerCase(), var3.toLowerCase())) {
                  return true;
               }
            }

            return false;
         } else {
            return true;
         }
      }
   }

   private void a(zpa var1, String var2) throws Exception {
      this.b(var1, var2);
   }

   private void b(zpa var1, String var2) throws Exception {
      boolean var3 = true;
      if (this.f != null) {
         var3 = this.f.getImportFormula();
      }

      String var4 = "xl/worksheets/" + var2;
      zaka var5 = new zaka(this.c, var1, var3);
      zcfw var6 = zasr.a(this.d, var4, true);
      var5.a(this.e);
      var5.a(var6);
      var6.c();
   }
}
